package com.xy.biz.fd.strategy.impl;

import com.xy.biz.fd.domain.bo.DocumentCodeRuleBO;
import com.xy.biz.fd.strategy.DocumentCodeGenerator;
import org.springframework.stereotype.Service;

import static com.xy.biz.fd.domain.req.documentCode.GetDocumentCodeRuleRequest.TYPE_GENERAL;
import static com.xy.biz.fd.strategy.DocumentCodeGenerator.PREFIX_DOCUMENT_CODE_GENERATOR;

@Service(PREFIX_DOCUMENT_CODE_GENERATOR + TYPE_GENERAL)
public class GeneralDocumentCodeGenerator implements DocumentCodeGenerator {

    @Override
    public String generate(DocumentCodeRuleBO documentCodeRuleBO) {
        return documentCodeRuleBO.getName() + "-" + String.format("%0" + documentCodeRuleBO.getShowLength() + "d", documentCodeRuleBO.getSerialNumber());
    }

}
